//===================================================================================
// $$
//
// Coder: Code Milker v1.0
// 0 - EntityName
// 1 - Properties
//===================================================================================


namespace App.Domain.Handlers {
    using System;
    using App.Data;
    using App.Domain.Contracts;
    using App.Domain.Models;

    public class CreateResume {
        private readonly IResumeRepository _resumeRepository;

        public CreateResume(IResumeRepository resumeRepository) {
            _resumeRepository = resumeRepository;
        }

        public void Execute(Guid userId, ICreateResumeCommand resumeForm) {
            if (resumeForm == null)
                throw new ArgumentNullException("resumeForm");

            try {
                var resume = resumeForm.ConvertToEntity();
                _resumeRepository.Create(resume);
            }
            catch (InvalidOperationException ex) {
                throw new BusinessServicesException("UnableToCreateVehicleExceptionMessage", ex);
            }
        }
    }
}
